﻿mainModule.factory("articleSvc", ["$http", "notification", "cache", function ($http, notification, cache) {
    return {
        findBy: function (query) {
            return $http.post('/api/articleapi/findby', { Value: query }).catch(function (ex) { notification.notify(ex) });
        },
        findNamesBy: function (query) {
            return $http.post('/api/articleapi/findnamesby', { Value: query }).catch(function (ex) { notification.notify(ex) });
        },
        findById: function (id) {
            return $http.get('/api/articleapi/' + id, { cache: cache }).catch(function (ex) { notification.notify(ex) });
        },

        edit: function (item) {
            return $http.put('/api/articleapi/' + item.ID, { Value: item }).catch(function (ex) { notification.notify(ex) });
        },

        add  :function(item){
            return $http.post('/api/articleapi/', { Value: item }).catch(function (ex) { notification.notify(ex) });
        },

        remove : function (id) {
            return $http.delete('/api/articleapi/' + id).catch(function (ex) { notification.notify(ex) });
        }
    }
}]);